/*
 * Copyright (c) 2019 Author: Fancyears Milos Malvis @1243093366@qq.com
 * ALL COPYRIGHT REVERSED.
 */

package com.fancyears.mq.consumer.topic;

import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.listener.api.ChannelAwareMessageListener;
import org.springframework.stereotype.Component;

/**
 * @Author: Fancyears Milos Malvis
 * @Date: Created in  2019/5/31 13:20
 * @Modified By:
 */
@Component
public class RabbitMqTopicErrorReceiver implements ChannelAwareMessageListener {
    @Override
    public void onMessage(Message message, Channel channel) throws Exception {
        try {
            System.out.println("************************TopicErrorReceiver********************************");
            System.out.println("主题模式 error 接收信息:" + new String(message.getBody()));
            System.out.println("********************************************************");
            //设置手工应答
            channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
        } catch (Exception e) {
            channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
        }
    }

}
